//
//  UIButton+Extension.swift
//  SinaWeiBo
//
//  Created by Vergil on 2017/5/3.
//  Copyright © 2017年 Vergil. All rights reserved.
//

import UIKit

extension UIButton {
    
    //UIButton 便利构造函数
    
    /// 遍历构造button
    ///
    /// - Parameters:
    ///   - title: 标题
    ///   - fontsize: 字体大小
    ///   - normalColor: normal颜色
    ///   - highlightColor: 高亮颜色
    ///   - bgImageName: 背景图片名字
    convenience init(title: String,fontsize: CGFloat = 16,normalColor: UIColor,highlightColor: UIColor,bgImageName: String) {
        
        self.init()
//        self.titleLabel?.text = title
        self.titleLabel?.font = UIFont.systemFont(ofSize: fontsize)
        self.setTitle(title, for: .normal)
        self.setTitleColor(normalColor, for: .normal)
        self.setTitleColor(highlightColor, for: .highlighted)
        self.setBackgroundImage(UIImage(named: bgImageName), for: .normal)
        self.setBackgroundImage(UIImage(named: bgImageName), for: .highlighted)
        
    }
    
}
